package com.smartwasser.yunhtgl.apphtgl.presenter;

import com.smartwasser.yunhtgl.apphtgl.bean.SPNormal3Bean;
import com.smartwasser.yunhtgl.apphtgl.network.RetrofitApi;
import com.smartwasser.yunhtgl.apphtgl.network.Retrofits;
import com.smartwasser.yunhtgl.apphtgl.utils.Logger;
import com.smartwasser.yunhtgl.apphtgl.view.SPNormal3View;

import rx.Observer;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

public class SPNormal3PresenterImpl implements SPNormal3Presenter {
    private SPNormal3View spNormal3View;

    public SPNormal3PresenterImpl(SPNormal3View spNormal3View) {
        this.spNormal3View = spNormal3View;
    }


    @Override
    public void getType1Sp1Great3(String JSESSIONID, String id) {
        Retrofits.getInstance().createReq(RetrofitApi.class).getType1Sp1Normal3(JSESSIONID, id)
                .subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Observer<SPNormal3Bean>() {
            @Override
            public void onCompleted() {
            }

            @Override
            public void onError(Throwable e) {
                Logger.e("onError_before");
                spNormal3View.error();
                Logger.e("onError");
            }

            @Override
            public void onNext(final SPNormal3Bean spNormal3Bean) {
                Logger.e("onNext_before");
                spNormal3View.success(spNormal3Bean);
                Logger.e("onNext");
            }
        });
    }
}